package game.Screens;

import game.ActionListener;
import game.Game;
import game.Config.Config;
import game.Config.Config.GameInput;
import game.Menus.TextMenuItem;
import game.Menus.VerticalMenu;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;

/**
 * This screen represent the main menu.
 * @author Sebastian Isheden and Victor Beer
 *
 */
public class MenuScreen extends Screen{
	VerticalMenu menu = new VerticalMenu(0,Config.MAIN_MENU_GAP);
	
	/**
	 * Initialzes the screen.
	 */
	@Override
	public void begin() {
		menu.addItem(new TextMenuItem("Start",new ActionListener() {
			@Override
			public void action() {
				startAction();
			}
		}));
		menu.addItem(new TextMenuItem("Help",new ActionListener() {
			@Override
			public void action() {
				helpAction();
			}
		}));
		menu.addItem(new TextMenuItem("Quit", new ActionListener() {
			@Override
			public void action() {
				quitAction();
			}
		}));
	}

	@Override
	public void end() {
	}

	@Override
	public void update(GameContainer gc, int delta) {
	}

	/**
	 * Check all the new input presses.
	 */
	@Override
	public void inputPressed(GameInput input) {
		if(input == GameInput.UP){
			menu.up();
		}
		if(input == GameInput.DOWN){
			menu.down();
		}
		if(input == GameInput.ACTION){
			menu.press();
		}
	}

	@Override
	public void inputDown(GameInput input) {
		// TODO Auto-generated method stub
		
	}

	/**
	 * Draws the screen.
	 */
	@Override
	public void draw(Graphics graphic) {
		Config.mainMenuBakground.draw();
		menu.draw(Config.MAIN_MENU_POSITION.copy(), graphic);
	}
	
	private void startAction(){
		Game.pushNewScreen(new DifficultyScreen());
	}
	private void helpAction(){
		Game.pushNewScreen(new HelpScreen());
	}
	private void quitAction(){
		Game.screenStack.pop();
		//TODO nice exit
	}



}
